#! /usr/bin/env perl
# author: maxiao
# date: 2023-03-07 22:56
# description: 欢迎提示语

use v5.20;
use utf8;


#sub greet{
#    state @menbers;
#    push @menbers, @_;
#    if ($#menbers == 0){
#        print "Hi @_! You are the first one here!\n";
#    }else{
#        print "Hi @_! @menbers[$#menbers - 1] is also here!\n";
#    }
#}
&greet("Fred");
&greet("Barney");
&greet("Wilma");
greet("Betty");

sub greet {
    state $last_name;
    my $name = shift;   # 等同于shift @_;
    print "Hi $name!";
    if ( defined($last_name) ) {
        print "$last_name is also here!\n";
    } else {
        print "You are the first one here!\n";
    }
    $last_name = $name;
}
